//
//  HYRoleDetailViewController.m
//  HaiYue
//
//  Created by skyline on 2018/1/25.
//  Copyright © 2018年 skyline. All rights reserved.
//

#import "HYRoleDetailViewController.h"
#import "HYRoleDetailHeaderView.h"
#import "HYRoleIMGView.h"
#import "HYToolBar.h"
#import "HYIMGScrollView.h"
@interface HYRoleDetailViewController ()<HYToolBarDelegate,HYRoleIMGViewDelegate>
@property (nonatomic, strong) UIScrollView *scroll;
@property (nonatomic, strong) HYRoleDetailHeaderView *roleHeaderView;
@property (nonatomic, strong) HYRoleIMGView *roleIMGView;
@property (nonatomic, strong) HYToolBar *toolBar;
@property (nonatomic, strong) HYIMGScrollView *IMGScrollView;
@end

@implementation HYRoleDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"角色详情";
    self.toolBar.hidden = NO;
    self.roleHeaderView.hidden = NO;
    self.roleIMGView.hidden = NO;
    self.scroll.contentSize = CGSizeMake(SCREEN_WIDTH, self.roleIMGView.bounds.size.height + self.roleHeaderView.bounds.size.height);
    // Do any additional setup after loading the view.
}

- (UIScrollView *)scroll
{
    if (!_scroll)
    {
        _scroll = [[UIScrollView alloc] init];
        _scroll.bounces = NO;
        [self.view addSubview:_scroll];
        [_scroll mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.mas_offset(UIEdgeInsetsMake(0, 0, self.toolBar.bounds.size.height, 0));
        }];
    }
    return _scroll;
}

- (HYIMGScrollView *)IMGScrollView
{
    if (!_IMGScrollView)
    {
       _IMGScrollView = [[HYIMGScrollView alloc] init];
        [[UIApplication sharedApplication].keyWindow addSubview:_IMGScrollView];
        [_IMGScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.mas_offset(UIEdgeInsetsZero);
        }];
    }
    return _IMGScrollView;
}

- (HYRoleDetailHeaderView *)roleHeaderView
{
    if (!_roleHeaderView)
    {
        _roleHeaderView = [[HYRoleDetailHeaderView alloc] init];
        [self.scroll addSubview:_roleHeaderView];
        [_roleHeaderView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.scroll);
            make.left.equalTo(self.view);
            make.right.equalTo(self.view);
        }];
    }
    return _roleHeaderView;
}

- (HYRoleIMGView *)roleIMGView
{
    if (!_roleIMGView)
    {
        _roleIMGView = [[HYRoleIMGView alloc] init];
        _roleIMGView.delegate = self;
        [self.scroll addSubview:_roleIMGView];
        [_roleIMGView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.roleHeaderView.mas_bottom);
            make.left.equalTo(self.view);
            make.right.equalTo(self.view);
        }];
    }
    return _roleIMGView;
}

- (HYToolBar *)toolBar
{
    if (!_toolBar)
    {
        _toolBar = [[HYToolBar alloc]initWithMiddleTitle:@"角色已经卖出" leftTitle:@"收藏" leftImageName:@"user" rightTitle:@"客服" rightImageName:@"userRed"];
        _toolBar.delegate = self;
        _toolBar.titleColor = THEME_COLOR;
        [_toolBar.leftBtn setTitleColor:ORANGE_COLOR forState:UIControlStateNormal];
        [_toolBar.rightBtn setTitleColor:ORANGE_COLOR forState:UIControlStateNormal];
        [self.view addSubview:_toolBar];
        [_toolBar mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.view);
            make.right.equalTo(self.view);
            make.bottom.equalTo(self.view);
            make.height.mas_equalTo(self.toolBar.bounds.size.height);
        }];
    }
    return _toolBar;
}

#pragma mark - HYToolBarDelegat
- (void)eventWithClicked:(HYToolBarEvent)event
{
    
}

#pragma mark - HYRoleIMGView
- (void)methodForHYRoleIMGViewDelegateWithImageNames:(NSArray *)imageNames index:(NSInteger)index
{
    self.IMGScrollView.hidden = NO;
    self.IMGScrollView.currentIndex = index;
    self.IMGScrollView.items = imageNames;
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
